import { createRouter, createWebHistory } from "vue-router";
// 导入组件
import Login from "@/views/login/Index.vue";
import Layout from "@/views/layout/Index.vue";
import Home from "@/views/home/Index.vue";
import Category from "@/views/category/Index.vue";
import SubCategory from "@/views/subCategory/Index.vue";
import Dateil from "@/views/detail/Index.vue";
import CartList from "@/views/cartList/index.vue";
import CheckOut from "@/views/checkOut/Index.vue";
import Pay from "@/views/pay/Index.vue";
import PayBack from "@/views/pay/PayBack.vue";
import Member from "@/views/member/Index.vue"
import UserInfo from '@/views/member/components/UserInfo.vue'
import UserOrder from '@/views/member/components/UserOrder.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      component: Layout,
      children: [
        {
          path: "",
          component: Home,
        },
        {
          path: "category/:id",
          component: Category,
        },
        {
          path: "category/sub/:id",
          component: SubCategory,
        },
        {
          path: "detail/:id",
          component: Dateil,
        },
        {
          path: "cartlist",
          component: CartList,
        },
        {
          path: "checkout",
          component: CheckOut,
        },
        {
          path: "pay",
          component: Pay,
        },
        {
          path: 'paycallback',
          component: PayBack,
        },
        {
          path:'member',
          component: Member,
          children: [
            {
              path: 'user',
              component: UserInfo
            },
            {
              path: 'order',
              component: UserOrder
            }
          ]
        }
      ],
    },
    {
      path: "/login",
      component: Login,
    },
  ],
  scrollBehavior() {
    return {
      top: 0,
    };
  },
});

export default router;
